process will remove the points corresponding to turns only after
it has removed all other route points.
- Both options only apply to route files from newer versions of
+ The 'split' option causes GPSBabel to create separate routes for
+ each street, creating a new route at each turn point. For obvious
+ reasons, 'split' cannot be used at the same time as the 'turns_only'
+ or 'turns_important' options.
+
+ All options only apply to route files from newer versions of
DeLorme software; older versions didn't store the turn information
with the route.
char *turns_important = NULL;
char *turns_only = NULL;
+char *split = NULL;
static
arglist_t saroute_args[] = {
NULL, ARGTYPE_BOOL },
{"turns_only", &turns_only, "Only read turns; skip all other points",
NULL, ARGTYPE_BOOL },
+ {"split", &split, "Split into multiple routes at turns",
+ NULL, ARGTYPE_BOOL },
{0, 0, 0, 0 }
};
rd_init(const char *fname)
{
infile = xfopen(fname, "rb", MYNAME);
+ if ( split && (turns_important || turns_only )) {
+ fatal( MYNAME
+ ": turns options are not compatible with split\n" );
+ }
}
static void
gbint32 lon;
} *latlon;
unsigned short coordcount;
- route_head *track_head;
+ route_head *track_head = NULL;
+ route_head *old_track_head = NULL;
waypoint *wpt_tmp;
ReadShort(infile); /* magic */
route_add_head(track_head);
}
while (count) {
+ old_track_head = NULL;
ReadShort(infile);
recsize = ReadLong(infile);
record = ReadRecord(infile, recsize);
stringlen = le_read16((unsigned short *)record);
+ if ( split && stringlen ) {
+ if ( track_head->rte_waypt_ct ) {
+ old_track_head = track_head;
+ track_head = route_head_alloc();
+ route_add_head( track_head );
+ } // end if
+ if ( !track_head->rte_name ) {
+ track_head->rte_name =
+ (char *)xmalloc(stringlen+1);
+ strncpy( track_head->rte_name,
+ record+2, stringlen );
+ track_head->rte_name[stringlen] = '\0';
+ }
+ }
+
coordcount = le_read16((unsigned short *)
(record + 2 + stringlen + 0x3c));
latlon = (struct ll *)(record + 2 + stringlen + 0x3c + 2);
wpt_tmp->route_priority=1;
sprintf( wpt_tmp->shortname, "\\%5.5x",
serial++ );
- if ( !turns_only || stringlen )
+ if ( !turns_only || stringlen ) {
route_add_wpt(track_head, wpt_tmp);
+ if ( old_track_head ) {
+ route_add_wpt(old_track_head,
+ waypt_dupe(wpt_tmp));
+ old_track_head = NULL;
+ }
+ }
+
latlon++;
coordcount--;